package hibernate.util;

import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

public class HibernateUtil {
	private static final SessionFactory sessionFactory;
	private static final SessionFactory sessionFactory2;
	
	private static String jDTS_Driver_cfg = "jTDS_hibernate.cfg.xml";
	private static String jDTS_TTLERP = "jTDS_TTLERP.cfg.xml";
			
	
	static {
		try {
			sessionFactory = new Configuration().configure(jDTS_Driver_cfg)
							.buildSessionFactory();
			System.out.println("\n"+sessionFactory+" ok \n");
			sessionFactory2 = new Configuration().configure(jDTS_TTLERP)
							.buildSessionFactory();		
			System.out.println("\n"+sessionFactory2+" ok \n");
			
		}catch (Throwable ex) {
			System.out.println("\n########## Session failed ##############################\n");
			System.err.println("Initial SessionFactory creation failed." + ex); 
			throw new ExceptionInInitializerError(ex); 
		}
	}
	
	
	public static SessionFactory getSessionFactory() {
		return sessionFactory;
	}

	public static SessionFactory getSessionFactory2() {
		return sessionFactory2;
	}		
}
